package com.zh.kotlin_mvvm.ftp.utils;

import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.Headers;
import com.zh.common.utils.ZSpUtils;
import com.zh.kotlin_mvvm.MyApp;
import com.zh.kotlin_mvvm.R;
import com.zh.kotlin_mvvm.ftp.SpKey;
import com.zh.kotlin_mvvm.ftp.XGConstant;
import com.zh.kotlin_mvvm.ftp.bean.AppAuthConfigBean1;
import com.zh.kotlin_mvvm.ftp.bean.LocalVideoInfo;
import com.zh.kotlin_mvvm.ftp.bean.PlayDownLoadInfo;
import com.zh.kotlin_mvvm.ftp.bean.VlcVideoBean;
import com.p2p.P2PClass;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import io.reactivex.disposables.Disposable;

public class XGUtil {
    public static Disposable disposable;

    /**
     * 记录最后一次播放的视频；
     * 用于软件启动的时候的提示 播放
     */
    public static void saveNextPlayItemVideo(List<LocalVideoInfo> videoitem) {
        try {
            ZSpUtils.INSTANCE.put(SpKey.NEXT_PLAY_VIDEO_ITEM, videoitem.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 加载电影列表
     */
    public static List<LocalVideoInfo> loadList() {
        try {
            String doneJson = ZSpUtils.INSTANCE.getString(SpKey.KEY_Dowanload_off, "");
            if (TextUtils.isEmpty(doneJson)) {
                return new ArrayList<>();
            } else {
                ArrayList<LocalVideoInfo> newList = GsonUtil.jsonToBeanList(doneJson, LocalVideoInfo.class);
                if (newList == null) {
                    return new ArrayList<>();
                } else {
                    return newList;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ArrayList<>();
    }

    /**
     * 保存电影列表
     */
    public static void saveList(List<LocalVideoInfo> list) {
        try {
            ZSpUtils.INSTANCE.put(SpKey.KEY_Dowanload_off, list.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 加载已完成电影列表
     */
    public static ArrayList<LocalVideoInfo> loadCacheList() {
        try {
            String doneJson = ZSpUtils.INSTANCE.getString(SpKey.KEY_Dowanload_done, "");
            if (TextUtils.isEmpty(doneJson)) {
                return new ArrayList<>();
            } else {
                ArrayList<LocalVideoInfo> newList = GsonUtil.jsonToBeanList(doneJson, LocalVideoInfo.class);
                if (newList == null) {
                    return new ArrayList<>();
                } else {
                    return newList;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ArrayList<>();
    }

    /**
     * 保存电影列表
     */
    public static void saveCacheList(List<LocalVideoInfo> list) {
        try {
            ZSpUtils.INSTANCE.put(SpKey.KEY_Dowanload_done, list.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 保存历史记录列表
     */
    public static void saveHistoryList(List<LocalVideoInfo> list) {
        try {
            ZSpUtils.INSTANCE.put(SpKey.KEY_Play_Record, list.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取历史记录列表
     */
    public static List<LocalVideoInfo> loadHistoryList() {
        try {
            String doneJson = ZSpUtils.INSTANCE.getString(SpKey.KEY_Play_Record, "");
            if (TextUtils.isEmpty(doneJson)) {
                return new ArrayList<>();
            } else {
                ArrayList<LocalVideoInfo> newList = GsonUtil.jsonToBeanList(doneJson, LocalVideoInfo.class);
                if (newList == null) {
                    return new ArrayList<>();
                } else {
                    return newList;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ArrayList<>();
    }


    /**
     * 退出程序
     * 保存历史记录列表
     */
    public static void saveSharedPreList(List<LocalVideoInfo> list) {
        try {
            ZSpUtils.INSTANCE.put(SpKey.KEY_SharePre_Default, list.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 退出程序
     * 获取历史记录列表
     */
    public static List<LocalVideoInfo> loadSharePreList() {
        try {
            String doneJson = ZSpUtils.INSTANCE.getString(SpKey.KEY_SharePre_Default, "");
            if (TextUtils.isEmpty(doneJson)) {
                return new ArrayList<>();
            } else {
                ArrayList<LocalVideoInfo> newList = GsonUtil.jsonToBeanList(doneJson, LocalVideoInfo.class);
                if (newList == null) {
                    return new ArrayList<>();
                } else {
                    return newList;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ArrayList<>();
    }

    /**
     * 退出程序（异常退出）
     * 保存记录列表
     */
    public static void saveSharedPreListExo(List<LocalVideoInfo> list) {
        try {
            ZSpUtils.INSTANCE.put(SpKey.KEY_SharePre_Default, list.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 退出程序（异常退出）
     * 获取历史记录列表
     */
    public static List<LocalVideoInfo> loadSharePreListExo() {
        try {
            String doneJson = ZSpUtils.INSTANCE.getString(SpKey.KEY_SharePre_Default, "");
            if (TextUtils.isEmpty(doneJson)) {
                return new ArrayList<>();
            } else {
                ArrayList<LocalVideoInfo> newList = GsonUtil.jsonToBeanList(doneJson, LocalVideoInfo.class);
                if (newList == null) {
                    return new ArrayList<>();
                } else {
                    return newList;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ArrayList<>();
    }

    /**
     * 保存下载记录列表
     */
    public static void saveDownList(Vector<LocalVideoInfo> downTaskPositionList) {
        saveSharedPreListExo(new ArrayList<>());
        MyApp.getInstance().getDownTaskPositionList3().clear();
        MyApp.getInstance().setDownTaskPositionList3(downTaskPositionList);
        List<LocalVideoInfo> mDataSharePre2 = new ArrayList<>();
        for (LocalVideoInfo item : MyApp.getInstance().getDownTaskPositionList3()) {
            mDataSharePre2.add(item);
            ZSpUtils.INSTANCE.put("is_data", true);

        }
        saveSharedPreListExo(mDataSharePre2);
    }

    public static void saveServiceDownList(Vector<LocalVideoInfo> downTaskPositionList) {
        ZSpUtils.INSTANCE.put(SpKey.KEY_Service_Download_List, downTaskPositionList.toString());
    }

    public static Vector<LocalVideoInfo> loadServiceDownList() {
        try {
            String doneJson = ZSpUtils.INSTANCE.getString(SpKey.KEY_Service_Download_List, "");
            if (TextUtils.isEmpty(doneJson)) {
                return new Vector<>();
            } else {
                Vector<LocalVideoInfo> newList = GsonUtil.jsonToBeanList(doneJson, LocalVideoInfo.class);
                if (newList == null) {
                    return new Vector<>();
                } else {
                    return newList;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Vector<>();
    }

    /**
     * 停止下载
     *
     * @param url        除了当前播放地址
     * @param isNetVideo ture是从网络资源点播过来的下载列表全部停止,也可以用来停止所有下载
     */
    public static void stopAll(String url, boolean isNetVideo) {
        List<PlayDownLoadInfo> downLoadInfos = loadPlaydownList();
        for (PlayDownLoadInfo downLoadInfo : downLoadInfos) {
            List<LocalVideoInfo> tmpData = downLoadInfo.getItemVideos();
//            List<LocalVideoInfo> tmpData = NewloadList();
            if (!TextUtils.isEmpty(url)) {
                boolean isDownLoadDone = false;//是否是已经下载完成的，已下载完成的不影响正在下载的电影
                for (LocalVideoInfo m : tmpData) {
                    if (m.getRunning().equals(LocalVideoInfo.running_finish)) {
                        isDownLoadDone = true;
                        break;
                    }
                }
                if (isDownLoadDone) {
                    //已下载完的视频不需要暂停其他下载的电影
//                    LogUtil.e("XGUtil", "stopAll==" + url);
                    return;
                }
            }
//            LogUtil.e("XGUtil", "stopAll===" + url + "====" + isNetVideo);

            saveSharedPreList(new ArrayList<>());
            List<LocalVideoInfo> mDataSharePre2 = new ArrayList<>();
            for (LocalVideoInfo item : MyApp.getInstance().getDownTaskPositionList()) {
                mDataSharePre2.add(item);
                ZSpUtils.INSTANCE.put("is_data", true);

            }

            saveSharedPreList(mDataSharePre2);

            MyApp.getInstance().getDownTaskPositionList().clear();
            for (LocalVideoInfo m : tmpData) {
                Log.e("kkkkkkkkkkkk22", url + "==" + m.getUrl());
                if (url.equals(m.getUrl())) {
                    //每次播放都会暂停所有下载，所有在这校验如果是播放的视频则继续下载
                    if (!MyApp.getInstance().getDownTaskPositionList().contains(m)) {//xxx0000308
                        MyApp.getInstance().getDownTaskPositionList().add(m);
                        XGUtil.saveDownList(MyApp.getInstance().getDownTaskPositionList());
                    }
                    m.setRunning(LocalVideoInfo.running_Star);
                } else {
//                LogUtil.e("XGUtil", "stopAll........" + m.getUrl());
                    try {
//                    int tid = Integer.valueOf(m.getTid());
//                    long dsize = XGApplication.getp2p().P2Pgetdownsize(tid);
//                    long fsize = XGApplication.getp2p().P2Pgetfilesize(tid);
//                    if (fsize == 0) {
//                        fsize = 1;
//                    }
                        if (m.isDone()) {
                            m.setRunning(LocalVideoInfo.running_finish);
                        } else {
                            MyApp.getInstance().getp2p().P2Pdoxpause(m.getUrl().getBytes("GBK"));
                            m.setRunning(LocalVideoInfo.running_Stop);
                        }
                        m.setSpeed_info("已暂停，点击继续下载");
//                m.setInfo(FileUtil.getSize(dsize) + "/" + FileUtil.getSize(fsize));
//                m.setInfo(FileUtil.getSize(fsize));
//                    m.setPercent((int) (1000 * dsize / fsize) + "");
                    } catch (UnsupportedEncodingException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        savePlaydownList(downLoadInfos);// 保存下载列表
    }

    //网络地址播放，不是本地服务器的资源，所以没有评论之类的东西
    public static void playXG(LocalVideoInfo info, final Activity activity) {
        playXG(info, activity, false);
    }

    //网络地址播放，不是本地服务器的资源，所以没有评论之类的东西
    public static void playXG(LocalVideoInfo info, final Activity activity, boolean isClose) {

//        if (null != disposable && !disposable.isDisposed()) {
//            disposable.dispose();
//        }
//        Observable.create(new ObservableOnSubscribe<Bundle>() {
//            @Override
//            public void subscribe(ObservableEmitter<Bundle> emitter) throws Exception {
        try {
            XGUtil.stopAll(info.getUrl(), false);

            // frag_ie.wvSaveState();
            String allurl = java.net.URLDecoder.decode(info.getUrl(), "UTF-8");
            String adurl = XGConstant.AdUrl;
            String referurl = "xghome://home";
            String[] urls = allurl.split("\\|");
            if (urls.length == 3) {
                adurl = urls[1];
                referurl = urls[2];
            }

            String newurl = urls[0].replace("xg://", "ftp://");
            String[] newurls = newurl.split("/");
            String title = newurls[newurls.length - 1];


            //:TJ:添加的修改的：兼容UC的Intent的JS
            if (newurl.contains("intent://")) {
                String[] newurls2 = newurl.split("#");
                newurls2 = newurls2[0].split("//");
                newurl = "ftp://" + newurls2[1];


            }
            //:9.4号添加 兼容 新的 xgplay://开头的视频的兼容
            if (newurl.contains("xgplay://")) {
                newurl = urls[0].replace("xgplay://", "ftp://");

            }

            boolean isDone = false;
            for (LocalVideoInfo localVideoInfo : loadCacheList()) {
                if (localVideoInfo.getUrl().equals(newurl)) {
                    isDone = true;
                }
            }
            if (!info.getUrl().contains("file://") && !isDone) {

                MyApp.getInstance().setTid(MyApp.getInstance().getp2p().P2Pdoxstart(newurl.getBytes("GBK")));
            } else {

                MyApp.getInstance().setTid(Integer.parseInt(info.getTid()));
                MyApp.getInstance().getp2p().P2Pdoxstart(newurl.getBytes("GBK"));
            }


            String currentUri = "http://127.0.0.1:" + P2PClass.port + "/" + URLEncoder.encode(Uri.parse(newurl).getLastPathSegment(), "GBK");

            Bundle mBundle = new Bundle();
            VlcVideoBean vlcVideoBean = new VlcVideoBean();
            if (info.getUrl().contains("file://")) {
                //本地视频
                vlcVideoBean.setVideoPlayUrl(info.getUrl());
            } else {
                vlcVideoBean.setVideoPlayUrl(currentUri);
            }

            vlcVideoBean.setDone(info.isDone());
            vlcVideoBean.setVideoHttpUrl(info.getUrl());
            vlcVideoBean.setVideoName(title);
            vlcVideoBean.setTid(MyApp.getInstance().getTid());
            vlcVideoBean.setVideoId(info.getVod_id());//从资源下载下来的可以看到详情信息
            vlcVideoBean.setTvPosition(info.getTvPosition());
            mBundle.putSerializable(XGConstant.KEY_DATA, vlcVideoBean);
//            Intent vintent = new Intent(activity, VideoInfoActivity.class);
//            vintent.putExtras(mBundle);
//            vintent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
//            activity.startActivity(vintent);
//            if (isClose) {
//                activity.finish();
//            }
//                    emitter.onNext(mBundle);
        } catch (Exception e) {
            e.printStackTrace();
//                    emitter.onNext(null);
        }
//            }
//        })

    }

    /**
     * 网络资源跳转过来的
     *
     * @param vlcVideoBean
     * @param activity
     * @param hasSeekToLastPlay 是否要跳转到电视剧上次播放的集数和位置
     */
    public static void playXG(VlcVideoBean vlcVideoBean, final Activity activity,
                              boolean hasSeekToLastPlay) {
//        Intent vintent = new Intent(activity, VideoInfoActivity.class);
//        Bundle mBundle = new Bundle();
//        mBundle.putSerializable(XGConstant.KEY_DATA, vlcVideoBean);
//        if (hasSeekToLastPlay) {
//            mBundle.putBoolean(XGConstant.KEY_DATA_2, true);
//        }
//        vintent.putExtras(mBundle);
//        vintent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
//        activity.startActivity(vintent);
    }

    /**
     * 网络资源->播放界面->服务器获取的地址
     *
     * @param urlByService
     */
    public static void getPlayUrl(String urlByService, GetVlcVideoBean getVlcVideoBean) {
        //暂停所有下载
        try {
//            XGUtil.stopAll(urlByService, true);
            XGUtil.stopAll(urlByService, true);
            String allurl = java.net.URLDecoder.decode(urlByService, "UTF-8");
            String adurl = XGConstant.AdUrl;
            String referurl = "xghome://home";
            String[] urls = allurl.split("\\|");
            if (urls.length == 3) {
                adurl = urls[1];
                referurl = urls[2];
            }

            String newurl = urls[0].replace("xg://", "ftp://");
            String[] newurls = newurl.split("/");
            String title = newurls[newurls.length - 1];


            //:TJ:添加的修改的：兼容UC的Intent的JS
            if (newurl.contains("intent://")) {
                String[] newurls2 = newurl.split("#");
                newurls2 = newurls2[0].split("//");
//                newurls2= newurl3.split("//");
                newurl = "ftp://" + newurls2[1];


            }
            //:9.4号添加 兼容 新的 xgplay://开头的视频的兼容
            if (newurl.contains("xgplay://")) {
                newurl = urls[0].replace("xgplay://", "ftp://");

            }
            Log.e("sssda", Thread.currentThread().getName());
            String currentUri = "http://127.0.0.1:" + P2PClass.port + "/" + URLEncoder.encode(Uri.parse(newurl).getLastPathSegment(), "GBK");
            VlcVideoBean vlcVideoBean = new VlcVideoBean();
            vlcVideoBean.setVideoPlayUrl(currentUri);
            vlcVideoBean.setVideoHttpUrl(urlByService);
            vlcVideoBean.setVideoName(title);
            int tid = 0;
            for (LocalVideoInfo localVideoInfo : loadCacheList()) {
                if (localVideoInfo.getUrl().equals(newurl)) {
                    tid = -1;
                }
            }
            if (tid == 0) {
                Log.e("getTime---080-", "playVideo：");
                MyApp.getInstance().setTid(MyApp.getInstance().getp2p().P2Pdoxstart(newurl.getBytes("GBK")));
                MyApp.getInstance().getp2p().P2Pdoxadd(urlByService.getBytes("GBK"));
//                XGApplication.getp2p().P2Pdoxdownload(urlByService.getBytes("GBK"));
            } else {
                MyApp.getInstance().setTid(tid);
                MyApp.getInstance().getp2p().P2Pdoxstart(newurl.getBytes("GBK"));
            }
            vlcVideoBean.setTid(MyApp.getInstance().getTid());
            getVlcVideoBean.getVlcVideoBean(vlcVideoBean);
//                    emitter.onNext(vlcVideoBean);
        } catch (Exception e) {
            e.printStackTrace();
//                    emitter.onNext(null);
        }

    }


    public interface GetVlcVideoBean {
        void getVlcVideoBean(VlcVideoBean vlcVideoBean);
    }

    /**
     * 加载电影列表
     */
    public static List<PlayDownLoadInfo> loadPlaydownList() {
        try {
            String doneJson = ZSpUtils.INSTANCE.getString(SpKey.KEY_Play_Download_List, "");
            if (TextUtils.isEmpty(doneJson)) {
                return new ArrayList<>();
            } else {
                ArrayList<PlayDownLoadInfo> newList = GsonUtil.jsonToBeanList(doneJson, PlayDownLoadInfo.class);
                if (newList == null) {
                    return new ArrayList<>();
                } else {
                    return newList;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ArrayList<>();
    }

    /**
     * 保存电影列表
     */
    public static void savePlaydownList(List<PlayDownLoadInfo> list) {
        try {
            ZSpUtils.INSTANCE.put(SpKey.KEY_Play_Download_List, list.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 加载app校验配置数据
     */
    public static AppAuthConfigBean1 loadAppAuthConfig() {
        try {
            String doneJson = ZSpUtils.INSTANCE.getString(SpKey.LIUMEITI_AppAuthConfig, "");
            if (TextUtils.isEmpty(doneJson)) {
                return new AppAuthConfigBean1();
            } else {
                AppAuthConfigBean1 newList = GsonUtil.jsonToBean(doneJson, AppAuthConfigBean1.class);
                if (newList == null) {
                    return new AppAuthConfigBean1();
                } else {
                    return newList;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new AppAuthConfigBean1();
    }

    /**
     * 保存app校验配置数据
     */
    public static void saveAppAuthConfig(AppAuthConfigBean1 list) {
        try {
            ZSpUtils.INSTANCE.put(SpKey.LIUMEITI_AppAuthConfig, list.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    //官方置顶评论


    public static void testReferer(Context context, String url, ImageView imageView, int position_s) {


        GlideUrl gliderUrl = new GlideUrl(url, getHeadr());
        //显示图片
        Glide.with(context)
                .asBitmap()
                .placeholder(position_s)
                .override(200, 300)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .load(gliderUrl)
                .into(imageView);

    }

    //一般用于头像
    public static void testReferer2(Context context, String url, ImageView imageView, int placeholder_id, int error) {

        GlideUrl gliderUrl = new GlideUrl(url, getHeadr());
        if (placeholder_id == 0 || error == 0) {
            Glide.with(context)
                    .load(gliderUrl)
                    .into(imageView);

        } else {
            Glide.with(context)
                    .load(gliderUrl)
                    .placeholder(placeholder_id)
                    .error(error)
                    .into(imageView);

        }


    }

    //不显示 override
    public static void testReferer3(Context context, String url, ImageView imageView, int position_s) {

        GlideUrl gliderUrl = new GlideUrl(url, getHeadr());
        if (position_s == 0) {
            //显示图片
            Glide.with(context)
                    .asBitmap()
                    .placeholder(R.mipmap.bg_video_plact_horizontal)
                    .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                    .load(gliderUrl)
                    .into(imageView);
        } else {
            //显示图片
            Glide.with(context)
                    .asBitmap()
                    .placeholder(0)
                    .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                    .load(gliderUrl)
                    .into(imageView);

        }

    }

    //不显示 asBitmap override 300 200比例
    public static void testReferer4(Context context, String url, ImageView imageView, int position_s) {

        GlideUrl gliderUrl = new GlideUrl(url, getHeadr());
        //显示图片
        Glide.with(context)
                .load(gliderUrl)
                .placeholder(position_s)
                .override(300, 200)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .into(imageView);

    }

    //自定义 override  比例
    public static void testReferer5(Context context, String url, ImageView imageView, int position_s, int overr_width, int overr_heigth) {

        GlideUrl gliderUrl = new GlideUrl(url, getHeadr());
        //显示图片
        Glide.with(context)
//                .asBitmap() //有的用到 有的没有用到
                .load(gliderUrl)
                .placeholder(position_s)
                .override(overr_width, overr_heigth)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .into(imageView);


    }


    //专用在启动页面
    public static void testReferer7(Context context, String url, ImageView imageView) {

        GlideUrl gliderUrl = new GlideUrl(url, getHeadr());
        Glide.with(context)
                .load(gliderUrl)

                .into(imageView);


    }

    public static Headers getHeadr() {
        Headers headers = new Headers() {
            @Override
            public Map<String, String> getHeaders() {
                Map<String, String> header = new HashMap<>();
                AppAuthConfigBean1 loadAppAuthConfig = XGUtil.loadAppAuthConfig();
                if (null != loadAppAuthConfig) {
                    header.put("Referer", loadAppAuthConfig.getData().getEr());
                    header.put("User-Agent", loadAppAuthConfig.getData().getUt() + PackageUtils.getVersionCode());
                    Log.e("---ip--0--pic", "Referer=" + loadAppAuthConfig.getData().getEr());
                    Log.e("---ip--0--pic", "User-Agent=" + loadAppAuthConfig.getData().getUt() + PackageUtils.getVersionCode());
                } else {
                    header.put("Referer", "referer.jianpianapp.com");
                    header.put("User-Agent", "jianpian-android/" + PackageUtils.getVersionCode());
                    Log.e("---ip--0--pic", "Referer=" + "referer.jianpianapp.com");
                    Log.e("---ip--0--pic", "User-Agent=" + "jianpian-android/" + PackageUtils.getVersionCode());
                }
                return header;
            }
        };
        return headers;
    }

}
